PROJECT (raspf)

#######################
#
# Parameters
#
#######################

# SET (CMAKE_VERBOSE_MAKEFILE ON)
SET ( TESTING TRUE )
SET ( DUMMY_DNS FALSE )
#ADD_DEFINITIONS ( -DDEBUG ) 

# make it position independant.
ADD_DEFINITIONS( -fPIC )


#######################
#
# Ragel "grammars"
#
#######################



#######################
#
# The Library
#
#######################


LINK_DIRECTORIES(udns hash bstrlib excc .)

ADD_CUSTOM_COMMAND ( OUTPUT validators.c
	COMMAND ragel ${raspf_SOURCE_DIR}/validators.ragel -C -o validators.c
                     DEPENDS validators.ragel )

ADD_LIBRARY ( raspf SHARED raspf.c validators.c )  
ADD_DEPENDENCIES (raspf udns hash bstrlib excc validators.ragel 
		  validators.c grammar ) 

TARGET_LINK_LIBRARIES ( raspf 	libudns.a 
				libhash.a 
				libbstrlib.a 
				libexcc.a
				m )



#######################
#
# The query tool
#
#######################

ADD_EXECUTABLE ( raspfquery raspfquery.c)
ADD_DEPENDENCIES (raspfquery raspf udns hash bstrlib)
TARGET_LINK_LIBRARIES ( raspfquery libudns.a
				   libhash.a
                                   libbstrlib.a
                                   libexcc.a
                                   raspf
				   m
                                   )


#######################
#
# Utility libraries
#
#######################

ADD_SUBDIRECTORY (udns)
ADD_SUBDIRECTORY (hash)
ADD_SUBDIRECTORY (bstrlib)
ADD_SUBDIRECTORY (excc)


#######################
#
# Test suites and stuff
#
#######################

IF ( TESTING )

IF ( DUMMY_DNS )
  ADD_DEFINITIONS ( -DUSE_DUMMY_DNS ) 
ENDIF ( DUMMY_DNS )
  
  FIND_LIBRARY (LIB_CHECK check)
  ADD_LIBRARY ( dummy_dns SHARED dummy_dns.c)  
  ADD_DEPENDENCIES (dummy_dns hash bstrlib excc) 
  TARGET_LINK_LIBRARIES ( dummy_dns   libhash.a 
                                      libbstrlib.a 
                                      libexcc.a
                                      m )

  ADD_CUSTOM_COMMAND ( OUTPUT testspf2.c 
                       COMMAND ${raspf_SOURCE_DIR}/gen_long_tests.py ${raspf_SOURCE_DIR}/rfc4408-tests-2007.01.yml ${raspf_SOURCE_DIR}/testspf2.c ${raspf_SOURCE_DIR}/rfc4408-zonedata/
                       DEPENDS gen_long_tests.py )

  ADD_CUSTOM_COMMAND ( OUTPUT testspf3.c 
                       COMMAND ${raspf_SOURCE_DIR}/gen_long_tests.py ${raspf_SOURCE_DIR}/rfc4408-devel.yml ${raspf_SOURCE_DIR}/testspf3.c ${raspf_SOURCE_DIR}/rfc4408-devel-zonedata/
                       DEPENDS gen_long_tests.py )

  IF (LIB_CHECK)

    ADD_EXECUTABLE ( testspf2 testspf2.c )  
    ADD_DEPENDENCIES (testspf2 raspf udns hash bstrlib rfc) 
    TARGET_LINK_LIBRARIES ( testspf2 raspf
                                    libudns.a 
                                    libhash.a 
                                    libbstrlib.a 
                                    libexcc.a
                                    m 
                                    ${LIB_CHECK} 
                                    )
  
    ADD_EXECUTABLE ( testspf3 testspf3.c )  
    ADD_DEPENDENCIES (testspf3 raspf udns hash bstrlib rfc) 
    TARGET_LINK_LIBRARIES ( testspf3 raspf
                                    libudns.a 
                                    libhash.a 
                                    libbstrlib.a 
                                    libexcc.a
                                    m 
                                    ${LIB_CHECK} 
                                    )
  
  
    ADD_EXECUTABLE ( testspf1 testspf1.c )  
    ADD_DEPENDENCIES (testspf1 raspf udns hash bstrlib rfc) 
    TARGET_LINK_LIBRARIES ( testspf1 raspf
                                    libudns.a 
                                    libhash.a 
                                    libbstrlib.a 
                                    libexcc.a
                                    m 
                                    ${LIB_CHECK} 
                                    )

  ENDIF (LIB_CHECK)

  ADD_CUSTOM_COMMAND ( TARGET testspf 
                       COMMAND cp ${raspf_SOURCE_DIR}/run_spf_suite2.py ${raspf_BINARY_DIR}
                       COMMAND cp ${raspf_SOURCE_DIR}/run_spf_suite3.py ${raspf_BINARY_DIR}
                       #COMMAND cp ${raspf_SOURCE_DIR}/spftest.txt ${raspf_BINARY_DIR}
                       )
ENDIF ( TESTING )

